package com.neutech.maplestory.util;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;

/**
 * 静态加载项目中所有图片资源
 */
public class ImageUtil {
    private static Map<String, Image> imagesMap = new HashMap<>();
    // 静态初始化
    static {
        // 远景
        imagesMap.put("BG",GameUtil.getImage("background/0"));
        // 背景
        imagesMap.put("bg",GameUtil.getImage("background/bg"));
        // LOGO
        imagesMap.put("logo",GameUtil.getImage("icon/logo"));
        //hero right stand
        for (int i = 0; i < 4; i++) {
            imagesMap.put("hero_right_stand" + i,GameUtil.getImage("hero/right/stand/stand1_" + i));
        }
        //hero left stand
        for (int i = 0; i < 4; i++) {
            imagesMap.put("hero_left_stand" + i,GameUtil.getImage("hero/left/stand/stand1_" + i));
        }
        //hero right walk
        for (int i = 0; i < 5; i++) {
            imagesMap.put("hero_right_walk" + i,GameUtil.getImage("hero/right/walk/walk1_" + i));
        }
        //hero left walk
        for (int i = 0; i < 5; i++) {
            imagesMap.put("hero_left_walk" + i,GameUtil.getImage("hero/left/walk/walk1_" + i));
        }
        //hero right prone
        imagesMap.put("hero_right_prone",GameUtil.getImage("hero/right/prone/prone_0"));
        //hero left prone
        imagesMap.put("hero_left_prone",GameUtil.getImage("hero/left/prone/prone_0"));
        //hero right jump
        imagesMap.put("hero_right_jump",GameUtil.getImage("hero/right/jump/jump_0"));
        //hero left jump
        imagesMap.put("hero_left_jump",GameUtil.getImage("hero/left/jump/jump_0"));

        //hero right shoot
        for (int i = 0; i < 4; i++) {
            imagesMap.put("hero_right_shoot" + i,GameUtil.getImage("hero/right/shoot/shoot1_" + i));
        }
        //hero left shoot
        for (int i = 0; i < 4; i++) {
            imagesMap.put("hero_left_shoot" + i,GameUtil.getImage("hero/left/shoot/shoot1_" + i));
        }
        //hero right arrow
        imagesMap.put("hero_right_arrow",GameUtil.getImage("arrow/right/hero_arrow"));
        //hero left arrow
        imagesMap.put("hero_left_arrow",GameUtil.getImage("arrow/left/hero_arrow"));
        // mob right stand
        for (int i = 0; i < 6; i++) {
            imagesMap.put("mob01_right_stand" + i,GameUtil.getImage("mob/mob01/right/stand/" + i));
        }
        // mob left stand
        for (int i = 0; i < 6; i++) {
            imagesMap.put("mob01_left_stand" + i,GameUtil.getImage("mob/mob01/left/stand/" + i));
        }
        // mob right walk
        for (int i = 0; i < 3; i++) {
            imagesMap.put("mob01_right_walk" + i,GameUtil.getImage("mob/mob01/right/walk/" + i));
        }
        // mob left walk
        for (int i = 0; i < 3; i++) {
            imagesMap.put("mob01_left_walk" + i,GameUtil.getImage("mob/mob01/left/walk/" + i));
        }
        // mob right hit
        imagesMap.put("mob_right_hit",GameUtil.getImage("mob/mob01/right/hit/0"));
        // mob left hit
        imagesMap.put("mob_left_hit",GameUtil.getImage("mob/mob01/left/hit/0"));
        // mob right die
        for (int i = 0; i < 11; i++) {
            imagesMap.put("mob01_right_die" + i,GameUtil.getImage("mob/mob01/right/die/" + i));
        }
        // mob left die
        for (int i = 0; i < 11; i++) {
            imagesMap.put("mob01_left_die" + i,GameUtil.getImage("mob/mob01/left/die/" + i));
        }
        // 普通小怪的血块
        imagesMap.put("blood",GameUtil.getImage("blood/blood"));
        // 人物血块
        imagesMap.put("hero_HP",GameUtil.getImage("hero/blood/0"));
        // 人物蓝块
        imagesMap.put("hero_MP",GameUtil.getImage("hero/blood/1"));
        // 道具
        imagesMap.put("HP_50",GameUtil.getImage("item/HP_50"));
        imagesMap.put("HP_100",GameUtil.getImage("item/HP_100"));
        imagesMap.put("HP_300",GameUtil.getImage("item/HP_300"));
        imagesMap.put("MP_100",GameUtil.getImage("item/MP_100"));
        // 道具包
        imagesMap.put("itemPackage",GameUtil.getImage("itemPackage/ItemPackage"));
        // 伤害值图片组(数字)
        for (int i = 0; i < 10; i++) {
            imagesMap.put("power" + i,GameUtil.getImage("power/" + i));
        }
        // 传送门
        for (int i = 0; i < 8; i++) {
            imagesMap.put("portal" + i,GameUtil.getImage("portal/" + i));
        }
    }
    private ImageUtil(){}

    /**
     * 通过图片对象的key获取图片对象
     * @param key 键
     * @return 图片对象
     */
    public static Image getImage(String key){
        return imagesMap.get(key);
    }

}
